package com.blb.exam.student.service.impl;

import com.blb.common.entity.User;
import com.blb.exam.student.dao.UserDAO;
import com.blb.exam.student.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDAO;

    @Override
    public User login(String username, String password) {
        return userDAO.selectByNameAndPassword(username,password);
    }

    @Override
    public void register(User user) {
        userDAO.insert(user);
    }

    @Override
    public boolean existsUsername(String username) {
        List<User> users = userDAO.selectByName(username);
        return users != null && !users.isEmpty();
    }
}
